﻿@model AutomatedTestDataManagement.Models.Page

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Page</legend>

        @Html.HiddenFor(model => model.PageID)
        @if (ViewBag.SiteID != null)
        {
            <input type="hidden" name="SiteID" id="SiteID" value="@ViewBag.SiteID" />
        }

        <div class="editor-label">
            @Html.LabelFor(model => model.PageName, "Page Name")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PageName)
            @Html.ValidationMessageFor(model => model.PageName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PagePath, "Relative Path")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PagePath)
            @Html.ValidationMessageFor(model => model.PagePath)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.PagesFields, "Fields on Page")
        </div>
        <div class="editor-field">
           <table>
               <tr>
                   <th>Field Name</th>
                   <th>Field Type</th>
                   <th></th>
               </tr>
               @Html.EditorFor(m => m.PagesFields)
               <tr>
                   <td colspan="2">
                       @if (ViewBag.SiteID != null)
                       {
                           @Html.ActionLink("Add Fields to Page", "Create", "PagesField", new { id = Model.PageID, siteID = ViewBag.SiteID }, null)
                       }
                       else
                       {
                            @Html.ActionLink("Add Fields to Page", "Create", "PagesField", new { id = Model.PageID }, null)
                       }
                   </td>
               </tr>
            </table>
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @if (ViewBag.SiteID != null)
    {
        @Html.ActionLink("Return to Page", "Edit", "Page", new { id = Model.PageID, siteID = ViewBag.SiteID }, null) @Html.Encode(" | ")
    }
    else
    {
        @Html.ActionLink("Return to Page", "Edit", "Page", new { id = Model.PageID }, null) @Html.Encode(" | ")
    }
    <div>
        @Html.Partial("_NavigationManagementNav")
    </div>

</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
